package com.icehand.demo.controller;

import com.icehand.demo.dto.OrderDTO;
import com.icehand.demo.service.OrderService;
import com.icehand.demo.vo.BaseResultVO;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class DemoController {
    @Qualifier("orderServiceV1")
    @Autowired
    private OrderService orderServiceV1;

    @Qualifier("orderServiceV2")
    @Autowired
    private OrderService orderServiceV2;

    @RequestMapping(value = "v1/order")
    @ResponseBody
    public BaseResultVO orderV1(OrderDTO dto) {
        return new BaseResultVO<>(orderServiceV1.handle(dto));
    }

    @RequestMapping(value = "v2/order")
    @ResponseBody
    public BaseResultVO orderV2(OrderDTO dto) {
        return new BaseResultVO<>(orderServiceV2.handle(dto));
    }
}
